package touchpad;

import java.util.LinkedList;
import java.util.List;

import android.view.MotionEvent;

public class TouchpadCommandGroup extends TouchpadCommand {

	private List<TouchpadCommand> commands;

	public TouchpadCommandGroup() {
		super(null);
		commands = new LinkedList<TouchpadCommand>();

	}

	@Override
	public boolean onUpTouch(MotionEvent m) {
		boolean success = true;
		for (TouchpadCommand c : commands) {
			if (!c.onUpTouch(m))
				success = false;
		}
		return success;

	}

	@Override
	public boolean onDownTouch(MotionEvent m) {
		boolean success = true;
		for (TouchpadCommand c : commands) {
			if (!c.onDownTouch(m))
				success = false;
		}
		return success;

	}

	@Override
	public boolean onMoveTouch(MotionEvent m) {
		boolean success = true;
		for (TouchpadCommand c : commands) {
			if (!c.onMoveTouch(m))
				success = false;
		}
		return success;

	}

	public void addTouchpadCommand(TouchpadCommand c) {
		commands.add(c);
	}

	public void removeTouchpadCommand(TouchpadCommand c) {
		commands.remove(c);
	}

	@Override
	public boolean onDownMultitouch(MotionEvent m) {
		boolean success = true;
		for (TouchpadCommand c : commands) {
			if (!c.onDownMultitouch(m))
				success = false;
		}
		return success;

	}

	@Override
	public boolean onUpMultitouch(MotionEvent m) {
		boolean success = true;
		for (TouchpadCommand c : commands) {
			if (!c.onUpMultitouch(m))
				success = false;
		}
		return success;

	}
}
